package com.bdk.middle.management.web;

import com.bdk.middle.common.result.web.ObjectResponse;
import com.bdk.middle.management.api.domain.AdminDO;
import com.bdk.middle.management.api.domain.RoleDO;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: xxx
 * @Date: 2021/3/3 0003 11:37
 * @Description:
 */

@RestController


public class TestController {

    @RequestMapping(value="/test", method = RequestMethod.POST)
    //@PreAuthorize("hasAuthority('view_product')")
    @PreAuthorize("hasRole('ROLE_superadmin')")
    @ResponseBody
    public String index() {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        Object o=authentication.getAuthorities();
        return "test";
    }
}
